<html>
<head><meta charset="utf-8"><title>How does rustc call the llvm functions? · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20does.20rustc.20call.20the.20llvm.20functions.3F.html">How does rustc call the llvm functions?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="229167975"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/How%20does%20rustc%20call%20the%20llvm%20functions%3F/near/229167975" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vikram Pal <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20does.20rustc.20call.20the.20llvm.20functions.3F.html#229167975">(Mar 07 2021 at 08:10)</a>:</h4>
<p>Hi, I am working on this pull request: <a href="https://github.com/rust-lang/rust/pull/80182">https://github.com/rust-lang/rust/pull/80182</a>. I found that in llvm, to print the symbolized backtraces, it uses a binary called <code>llvm-symbolizer</code>. My question, is this binary available for rustc? Also, in general, does rustc invoke llvm through binaries or directly calls the C++ code e.g. for code generation?</p>
<p>I found, the build produces some llvm binaries in <code>x86_64-unknown-linux-gnu/ci-llvm/bin</code> like <code>llvm-ar</code> but no <code>llvm-symbolizer</code>.</p>



<a name="229178098"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/How%20does%20rustc%20call%20the%20llvm%20functions%3F/near/229178098" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20does.20rustc.20call.20the.20llvm.20functions.3F.html#229178098">(Mar 07 2021 at 10:55)</a>:</h4>
<p>Rustc never invokes any LLVM binaries. It always uses the C api.</p>



<a name="229178240"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/How%20does%20rustc%20call%20the%20llvm%20functions%3F/near/229178240" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20does.20rustc.20call.20the.20llvm.20functions.3F.html#229178240">(Mar 07 2021 at 10:58)</a>:</h4>
<p>The backtrace crate uses the addr2line crate for backtrace symbolication. For this the backtrace crate does need to read the files containing the debuginfo, so it is not exactly easy to use addr2line without backtrace.</p>



<a name="229187336"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/How%20does%20rustc%20call%20the%20llvm%20functions%3F/near/229187336" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vikram Pal <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20does.20rustc.20call.20the.20llvm.20functions.3F.html#229187336">(Mar 07 2021 at 13:24)</a>:</h4>
<p>will the backtrace crate be allowed to be used in rustc?</p>



<a name="229189086"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/How%20does%20rustc%20call%20the%20llvm%20functions%3F/near/229189086" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20does.20rustc.20call.20the.20llvm.20functions.3F.html#229189086">(Mar 07 2021 at 13:51)</a>:</h4>
<p>The backtrace crate is already used by libstd to provide backtraces for <code>RUST_BACKTRACE=1</code>.</p>



<a name="229190445"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/How%20does%20rustc%20call%20the%20llvm%20functions%3F/near/229190445" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vikram Pal <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20does.20rustc.20call.20the.20llvm.20functions.3F.html#229190445">(Mar 07 2021 at 14:11)</a>:</h4>
<p>ok, also I found llvm symbolizer does not seem to have a C api.</p>



<a name="229196976"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/How%20does%20rustc%20call%20the%20llvm%20functions%3F/near/229196976" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20does.20rustc.20call.20the.20llvm.20functions.3F.html#229196976">(Mar 07 2021 at 15:46)</a>:</h4>
<p>rustc also makes C++ calls -- see <code>compiler/rustc_llvm/llvm-wrapper</code></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>